<script setup>
import {defineComponent, ref, toRefs, reactive, onMounted, watch, toRaw, onUnmounted, computed, inject} from 'vue';
import List from "../../components/List.vue";
import {useStore} from "vuex";
import TarBar from "../../components/TarBar.vue";
import Search from "../../components/Search.vue";

const store = useStore()
const $axios = inject('$axios')
const $api = inject('$api')

const list = ref([])
const params = ref({
  keyWord: '',
  pageNo: 1,
  pageSize: 20,
  tabType: 1,//当前tab页类型:0全部微信好友，1我的微信好友，2继承的微信好友，3下属的微信好友，不传默认我的微信好友
})

onMounted(() => {
  getList()
})

function getList() {
  $axios.$get($api.API.weChatFriends.list, params.value).then((res) => {
    console.log(res);
    let {code, result} = res
    if (code === 200) {
      list.value = result.records || []
    }

  }).catch(err => {
    list.value = [
      {
        "id": "1785242838142291970",
        "wxHeadImg": "http://wx.qlogo.cn/mmhead/1CHHx9Yq4nEl4Gkx0s1gUUmP3VAH7T0Vsr96NicUd5nCncM8r8ygEMw/0",
        "externalUserid": "wmIz8FCgAAAAsIY35kMUuP5ZUaifI7GQ",
        "name": "伍斌",
        "companyName": "广州市天龙八部有限公司",
        "shortName": "",
        "phone": "18126549887",
        "clueId": "1735935513514778625",
        "lastFollowTime": "2024-04-30 17:40:35"
      },
      {
        "id": "1785242836116443137",
        "wxHeadImg": "http://wx.qlogo.cn/mmhead/2pm5Nb2cMaMRaf0JUCVAOkQsJichADjIes854NGXmb8N94XXktia8UHg/0",
        "externalUserid": "wmIz8FCgAAOLQvLY8rhwbF7n-52aVTPA",
        "name": "name",
        "companyName": "新增个线索测试电话存档",
        "shortName": "",
        "phone": "15766667777",
        "clueId": "1793541834700537857",
        "lastFollowTime": "2024-04-30 17:40:35"
      },
      {
        "id": "1785242834413555713",
        "wxHeadImg": "http://wx.qlogo.cn/mmhead/mN2nq6hm9egdc9AeTPgZux7ojEjhtphib32EBd8PStW6B2Xup8kCibZcnicTzcdxvibicXEyEhoH0RaY/0",
        "externalUserid": "wmIz8FCgAA5b0KOBOZOchNt6htyIMybg",
        "name": "w",
        "companyName": null,
        "shortName": "",
        "phone": null,
        "clueId": null,
        "lastFollowTime": "2024-04-30 17:40:35"
      },
      {
        "id": "1785242833104932865",
        "wxHeadImg": "http://wx.qlogo.cn/mmhead/Q3auHgzwzM54cvcwb5bMDR5nCQt8keDaoVxiaovibfJOvkM0chMoL5icw/0",
        "externalUserid": "wmIz8FCgAAz_9hwtbyrlYtnYzTnwy7IA",
        "name": "东隅\uD83D\uDE1C",
        "companyName": "东隅\uD83D\uDE1C",
        "shortName": "",
        "phone": null,
        "clueId": "1793577657781264385",
        "lastFollowTime": "2024-04-30 17:40:34"
      },
      {
        "id": "1785242831406239746",
        "wxHeadImg": "http://wx.qlogo.cn/mmhead/j8JSzC6ialBaVA05LZAyFA9flOQKOwN2jt33XaWaEaEaq7IATPQ1VbUeAVZ7NY9Aibq5Txm8puBzg/0",
        "externalUserid": "wmIz8FCgAAP8E57RGXJyL76MUN81eCOw",
        "name": "灵犀",
        "companyName": null,
        "shortName": "",
        "phone": null,
        "clueId": null,
        "lastFollowTime": "2024-04-30 17:40:34"
      },
      {
        "id": "1785242830017925121",
        "wxHeadImg": "http://wx.qlogo.cn/mmhead/iahdQicCC5VBTX5wZQh6WQticXnjFut3MXsiboP8dQTsxac8ibuqdxnKC3Q/0",
        "externalUserid": "wmIz8FCgAAiKibNfeRDnbSg2NwjLchiw",
        "name": "乂日光倾城¤",
        "companyName": null,
        "shortName": "",
        "phone": null,
        "clueId": null,
        "lastFollowTime": "2024-04-30 17:40:34"
      },
      {
        "id": "1785242828327620609",
        "wxHeadImg": "http://wx.qlogo.cn/mmhead/9gLecpvBVsXncvpwiboS77VJIfvsrQpaibDibchHSgeGsGexu7c5fLLSsvO2xLTbib5p58yfARzycXY/0",
        "externalUserid": "wmIz8FCgAATZLQTpLJIrybFT3coaM6Jw",
        "name": "竹君",
        "companyName": null,
        "shortName": "",
        "phone": null,
        "clueId": null,
        "lastFollowTime": "2024-04-30 17:40:33"
      },
      {
        "id": "1785242826574401537",
        "wxHeadImg": "http://wx.qlogo.cn/mmhead/kqodNCVWpEuMJ4hPdH0Hc4jibZ6Tkzo24os6fNia4VqICQj4g0FE1uqA/0",
        "externalUserid": "wmIz8FCgAAyddJ7Q2Du1bzD7kJ_ltDVw",
        "name": "\uD83D\uDC2E",
        "companyName": null,
        "shortName": "",
        "phone": null,
        "clueId": null,
        "lastFollowTime": "2024-04-30 17:40:33"
      },
      {
        "id": "1760855062448041985",
        "wxHeadImg": "http://wx.qlogo.cn/mmhead/PiajxSqBRaEJOUomZOLNvXBktGglFtbhzWXnESp50LicMjBGzmxqdBeQ/0",
        "externalUserid": "wmIz8FCgAArxZ1uf4BfplcJMgU4DCkPA",
        "name": "向阳",
        "companyName": "深圳市向阳科技有限公司",
        "shortName": "向阳科技",
        "phone": null,
        "clueId": "1761308630204399618",
        "lastFollowTime": "2024-02-23 10:32:16"
      }
    ]
  })
}

function onSearch() {

}

const menuType = ref('');
const menuList = [
  {text: '我的微信好友', value: 1},
  {text: '继承的微信好友', value: 2},
  {text: '下属的微信好友', value: 3},
  {text: '全部微信好友', value: ''},
];
</script>

<template>
  <TarBar/>
  <div class="menu_wrap">
    <van-dropdown-menu>
      <van-dropdown-item v-model="menuType" :options="menuList"/>
    </van-dropdown-menu>
  </div>
  <Search/>
  <List :list="list"/>
</template>

<style scoped lang="less">
.menu_wrap {
  width: 160px;
}
</style>